package com.xiaotu.util;

/**
 * @author zhangxiao
 * @create 2021-08-31 15:29
 */
public class RedisKeyUtils {

    /**
     * @param commentId 评论id
     * @return
     */
    public static String getIsLikedKey(Integer commentId, Boolean isLike) {
        StringBuilder builder = new StringBuilder();
        builder.append("commentId");
        builder.append(":");
        if (isLike) {
            builder.append("like");
        } else {
            builder.append("notLike");
        }
        builder.append(":");
        builder.append(commentId);
        return builder.toString();
    }

    /**
     * @return
     */
    public static String getHashKey(Integer commentId, Integer userId) {
        StringBuilder builder = new StringBuilder();
        builder.append(commentId);
        builder.append(":");
        builder.append(userId);
        return builder.toString();
    }

    /**
     * @param commentId 评论id
     * @return
     */
    public static String getIsLikedCountKey(Integer commentId, Boolean isLike) {
        StringBuilder builder = new StringBuilder();
        builder.append("commentId");
        builder.append(":");
        if (isLike) {
            builder.append("likeCount");
        } else {
            builder.append("notLikeCount");
        }
        builder.append(":");
        builder.append(commentId);
        return builder.toString();
    }

}
